# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# 标准库
import os
import sys

file_path = os.path.join(
    os.path.dirname(__file__), "external-libraries"
)
if file_path not in sys.path:
    sys.path.insert(0, file_path)

PROJECT_DIR = os.path.dirname(__file__)

if (not os.path.exists(os.path.join(PROJECT_DIR, "ip-adapter"))) and (not os.path.exists(os.path.join(PROJECT_DIR, "Pony_Pencil-Xl-V1.0.2"))):
    os.system(f'''cd {PROJECT_DIR}
git lfs install
git clone http://git.aistudio.baidu.com/2510368/Paddle-Stable-Diffusion.git
cp -rf Paddle-Stable-Diffusion/ip-adapter .
cp -rf Paddle-Stable-Diffusion/Pony_Pencil-Xl-V1.0.2 .
rm -rf Paddle-Stable-Diffusion
'''
    )

from utils.webui_adapter import main

main()
